import {fileURLToPath, URL} from 'node:url'

import {defineConfig, loadEnv} from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'

import {createRequire} from 'node:module';

const require = createRequire(import.meta.url);

// @ts-ignore
import ckeditor5 from '@ckeditor/vite-plugin-ckeditor5';


// https://vitejs.dev/config/
export default defineConfig(({command, mode}) => {
    const env = loadEnv(mode, process.cwd())
    return {
        base: "./",
        plugins: [vue(), vueJsx(),
            ckeditor5({
                theme: require.resolve('@ckeditor/ckeditor5-theme-lark')
            })
        ],
        resolve: {
            alias: {
                '@': fileURLToPath(new URL('./src', import.meta.url))
            }
        },
        server: {
            host: '0.0.0.0',
            port: 3000,
            proxy: {
                "/api": {
                    target: 'http://127.0.0.1:8081',
                    changeOrigin: true,
                }
            },
        },
    }
})
